package org.xiong.disk.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Msg {
    private int code;
    private String msg;
    // 用户返回给浏览器的数据
    private Map<String,Object> extend = new HashMap<String, Object>();

    public static Msg success(String successMsg){
        Msg message = new Msg();
        message.setCode(100);
        message.setMsg(successMsg);
        return message;
    }
    public static Msg fail(String failMsg){
        Msg message = new Msg();
        message.setCode(200);
        message.setMsg(failMsg);
        return message;
    }
    public Msg add(String key,Object value){
        this.getExtend().put(key,value);
        return this;
    }
}
